﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HHMMS.Core.Model;
using Bingosoft.Data;
using Bingosoft.RestService.Attributes;
using System.Data;

namespace HHMMS.Core.Service
{
    [Service("MaterialsProvider")]
    public class MaterialsProvider
    {
        #region --数据操作对象
        private readonly Dao dao = Dao.Get();
        #endregion

        [ServiceMethod]
        public object GetMaterialsinfo(string materialsNo)
        {
            Materialsinfo mi = dao.QueryEntity<Materialsinfo>("SELECT top 1 MaterialsNo,MaterialsName,MaterialsModel,Unit,price FROM MaterialDirectory md WHERE md.MaterialsNo=@MaterialsNo", new { MaterialsNo = materialsNo });
            if (mi != null)
            {
                return new { MaterialsName = mi.MaterialsName, MaterialsModel = mi.MaterialsModel, Unit = mi.Unit, Price = mi.Price };
            }
            else
            {
                return null;
            }
        }

        [ServiceMethod]
        public DataTable GetChart(string locomotiveNo)
        {
            DataTable dt= dao.QueryDataSet("Delivered.GetChart", new
            {
                LocomotiveNo = locomotiveNo
            }).Tables[0];
            return dt;
        }
    }
}
